package com.battle.service.controller.web;

import com.battle.pojo.param.sirens.*;
import com.battle.pojo.vo.sirens.*;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
 * web/警情MP表
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/sirens/web")
public class SirensWebController {

    private final SirensService service;

    public SirensWebController(SirensService service) {
        this.service = service;
    }


    /**
     * 创建警情MP表
     *
     * @param param
     * @return
     */
    @PostMapping("/createSirens")
    public ApiResult createSirens(@RequestBody @Valid CreateSirensParam param) {
        service.createSirens(param);
        return ApiResult.ok();
    }


    /**
     * 修改警情MP表
     *
     * @param param
     */
    @PutMapping("/editSirens")
    public ApiResult editSirens(@RequestBody @Valid EditSirensParam param) {
        service.editSirens(param);
        return ApiResult.ok();
    }

    /**
     * 移除警情MP表
     *
     * @param id
     */
    @DeleteMapping("/removeSirens")
    public ApiResult removeSirens(@RequestParam("id") Long id) {
        service.removeSirens(id);
        return ApiResult.ok();
    }

    /**
     * 启动/禁用警情MP表
     *
     * @param id
     */
    @GetMapping("/enabledSirens")
    public ApiResult enabledSirens(@RequestParam("id") Long id) {
        service.enabledSirens(id);
        return ApiResult.ok();
    }

    /**
     * 获取警情MP表详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getSirens")
    public ApiResult<GetSirensVo> getSirens(@RequestParam("id") Long id) {
        GetSirensVo vo = service.getSirens(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取警情MP表列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getSirensList")
    public ApiResult<PageResult<GetSirensListVo>> getSirensList(@RequestBody GetSirensListParam param) {
        PageResult<GetSirensListVo> result = service.getSirensList(param);
        return ApiResult.ok(result);
    }


    /**
     * 获取没有关联过的警情MP表下拉列表
     *
     * @return
     */
    @PostMapping("/getSirensDownList")
    public ApiResult<List<GetSirensDownListVo>> getSirensDownList(@RequestBody(required = false) @Valid GetSirensDownListParam param) {
        List<GetSirensDownListVo> list = service.getSirensDownList(param);
        return ApiResult.ok(list);
    }


}

